﻿using System;
using System.IO;
using FunctionalCLR.Core;

namespace FunctionalCLR.Shell.Function.IO {

    /// <summary>
    /// Rename
    /// move("c:\\hello.txt", "c:\\helloworld.txt");
    /// 
    /// Move
    /// move("c:\\hello.txt", "c:\\hello\\hello.txt");
    /// </summary>
    public class FileMoveNode : FuncNode {

        public FileMoveNode()
            : base() {
            base.Value = "Move";
        }

        public override object Evaluate() {
            string newName = Children[0].Evaluate().ToString();
            string oldName = Children[1].Evaluate().ToString();
            File.Move(oldName, newName);

            return newName;
        }
    }
}
